#include "disk.h"
#include "realthunk.h"
#include "algorithms.h"

namespace disk
{
  void read_sectors(void* out, uint64_t sector_start, uint sector_count)
  {
    for (uint64_t i = 0; i < sector_count; ++i)
    {
      real_thunk::read_1sector_params r1s;
      r1s.hdr.func_type = real_thunk::READ_1SECTOR;
      r1s.sector_start = sector_start;
      r1s.out = out;
      real_thunk::func((void*)(&r1s), sizeof(r1s));

      out = static_cast<void*>(static_cast<uint8_t*>(out) + SECTOR_SIZE);
      ++sector_start;
    }
  }

  void write_sectors(void* in, uint64_t sector_start, uint sector_count)
  {
    for (uint64_t i = 0; i < sector_count; ++i)
    {
      real_thunk::write_1sector_params w1s;
      w1s.hdr.func_type = real_thunk::WRITE_1SECTOR;
      w1s.sector_start = sector_start;
      w1s.in = in;
      real_thunk::func((void*)(&w1s), sizeof(w1s));

      in = static_cast<void*>(static_cast<uint8_t*>(in) + SECTOR_SIZE);
      ++sector_start;
    }
  }
}
